import cv2
capture = cv2.VideoCapture(1)
capture.set(3,1280)
capture.set(4,720)

if __name__ == "__main__":
    i = 1
    while True:
        ret, frame = capture.read()
        # frame = cv2.flip(frame,1)   #镜像操作

        cv2.imshow("video", frame)
        key = cv2.waitKey(50)
        #print(key)
        if key == ord('s'):  #判断是哪一个键按下
            picname = 'D:\\GraduationProject\\USBCameraPic\\' + str(i) + '.jpg'
            cv2.imwrite(picname,frame)
            i = i + 1

    cv2.destroyAllWindows()